package com.ndp.fb.rdb.db.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.ndp.fb.rdb.api.EcElementStyleColorTypeRdbService;
import com.ndp.fb.rdb.db.DaoTemplate;
import com.ndp.fb.rdb.db.impl.mapper.DefaultRowMapper;
import com.ndp.fb.rdb.model.ectemplate.EcElementStyleColorType;
import com.ndp.fb.rdb.model.ectemplate.EcElementStyleColorTypeShowResult;

/**
 * Created by sisi.chen on 2016/8/2.
 */
@Service
public class EcElementStyleColorTypeRdbServiceImpl extends DaoTemplate implements EcElementStyleColorTypeRdbService{
    @Override
    public EcElementStyleColorTypeShowResult findByElementStyleId(Integer elementStyleGroupId) {
        String sql = "select sc.*, color.name as element_color_name from ec_element_style_color_type sc, ec_color_type color\n" +
                "where sc.element_color_type_id = color.id\n" +
                "and sc.element_style_id = ?;";
        return findOne(sql, new Object[]{elementStyleGroupId}, DefaultRowMapper.autoRowMapper(EcElementStyleColorTypeShowResult.class));
    }

    @Override
    public Long save(EcElementStyleColorType ecElementStyleColorTypeShowResult) {
        return saveResultId(ecElementStyleColorTypeShowResult);
    }
}
